using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace BMC.ARSystem
{
	[ARStructTypeInfo(Name = "ARSvcActionStruct", NumberOfMembers = 7u), ClassInterface, Guid("3737c186-c73d-43d2-8384-985239b2f8b7"), ProgId("BMC.ARSystem.ServiceAction")]
	public class ServiceAction : Action
	{
		private string _serverName;
		private string _serviceForm;
		private int _requestIdMap;
		private ArrayList _inputFieldMapping;
		private ArrayList _outputFieldMapping;
		private string _sampleServer;
		private string _sampleForm;
		public string ServerName
		{
			get
			{
				return this._serverName;
			}
			set
			{
				this._serverName = value;
			}
		}
		public string FormName
		{
			get
			{
				return this._serviceForm;
			}
			set
			{
				this._serviceForm = value;
			}
		}
		public int RequestIdMap
		{
			get
			{
				return this._requestIdMap;
			}
			set
			{
				this._requestIdMap = value;
			}
		}
		public ArrayList InputFieldMapping
		{
			get
			{
				return this._inputFieldMapping;
			}
			set
			{
				this._inputFieldMapping = value;
			}
		}
		public ArrayList OutputFieldMapping
		{
			get
			{
				return this._outputFieldMapping;
			}
			set
			{
				this._outputFieldMapping = value;
			}
		}
		public string SampleServer
		{
			get
			{
				return this._sampleServer;
			}
			set
			{
				this._sampleServer = value;
			}
		}
		public string SampleForm
		{
			get
			{
				return this._sampleForm;
			}
			set
			{
				this._sampleForm = value;
			}
		}
		public ServiceAction()
		{
		}
		internal ServiceAction(object[] rawData, Server server)
		{
			Session arg_2C_0 = server.Session;
			int[] indexSpec = new int[1];
			arg_2C_0.SecondaryServerName = (this.ServerName = (string)Util.GetAt(rawData, indexSpec));
			server.Session.CurrentRemoteForm = (this.FormName = (string)Util.GetAt(rawData, new int[]
			{
				1
			}));
			if (server.Session.SecondaryServerName != null && (server.Session.SecondaryServerName.Equals("@") || server.Session.SecondaryServerName.EndsWith("*")))
			{
				server.Session.SecondaryServerName = server.Session.PrimaryServerName;
			}
			if (server.Session.CurrentRemoteForm != null && (server.Session.CurrentRemoteForm.Equals("@") || server.Session.CurrentRemoteForm.Equals("*") || server.Session.CurrentRemoteForm.Equals("CURRENT SCREEN") || server.Session.CurrentRemoteForm.Equals("CURRENT TRANSACTION")))
			{
				server.Session.CurrentRemoteForm = server.Session.CurrentLocalForm;
			}
			this.RequestIdMap = Convert.ToInt32(Util.GetAt(rawData, new int[]
			{
				2
			}));
			string currentLocalForm = server.Session.CurrentLocalForm;
			string currentRemoteForm = server.Session.CurrentRemoteForm;
			server.Session.CurrentLocalForm = currentRemoteForm;
			server.Session.CurrentRemoteForm = currentLocalForm;
			bool flag;
			bool flag2;
			this.InputFieldMapping = Util.BuildFieldAssignmentList(Util.GetAt(rawData, new int[]
			{
				3
			}), server.Session.GetServer(server.Session.SecondaryServerName), server.Session.CurrentLocalForm, server.Session.CurrentRemoteForm, out flag, out flag2);
			server.Session.CurrentLocalForm = currentLocalForm;
			server.Session.CurrentRemoteForm = currentRemoteForm;
			this.OutputFieldMapping = Util.BuildFieldAssignmentList(Util.GetAt(rawData, new int[]
			{
				4
			}), server.Session.GetServer(server.Session.SecondaryServerName), server.Session.CurrentLocalForm, server.Session.CurrentRemoteForm, out flag, out flag2);
			this.SampleServer = (string)Util.GetAt(rawData, new int[]
			{
				5
			});
			this.SampleForm = (string)Util.GetAt(rawData, new int[]
			{
				6
			});
		}
		internal static ServiceAction createInstance(object[] rawData, Server server)
		{
			return new ServiceAction(rawData, server);
		}
		internal static object ToVariant(object given, Server server)
		{
			ServiceAction serviceAction = given as ServiceAction;
			if (serviceAction == null)
			{
				return given;
			}
			object[] array = new object[7];
			array[0] = serviceAction.ServerName;
			array[1] = serviceAction.FormName;
			array[2] = serviceAction.RequestIdMap;
			server.Session.PrimaryServerName = server.ServerName;
			server.Session.SecondaryServerName = serviceAction.ServerName;
			if (server.Session.SecondaryServerName != null && server.Session.SecondaryServerName.StartsWith("$") && server.Session.SecondaryServerName.EndsWith("$"))
			{
				server.Session.SecondaryServerName = serviceAction.SampleServer;
			}
			if (server.Session.SecondaryServerName != null && (server.Session.SecondaryServerName.Equals("@") || server.Session.SecondaryServerName.Equals("*") || server.Session.SecondaryServerName.Equals("CURRENT SCREEN") || server.Session.SecondaryServerName.Equals("CURRENT TRANSACTION")))
			{
				server.Session.SecondaryServerName = server.Session.PrimaryServerName;
			}
			server.Session.CurrentRemoteForm = serviceAction.FormName;
			if (server.Session.CurrentRemoteForm.StartsWith("$") && server.Session.CurrentRemoteForm.EndsWith("$"))
			{
				server.Session.CurrentRemoteForm = serviceAction.SampleForm;
			}
			if (server.Session.CurrentRemoteForm != null && (server.Session.CurrentRemoteForm.Equals("@") || server.Session.CurrentRemoteForm.Equals("*") || server.Session.CurrentRemoteForm.Equals("CURRENT SCREEN") || server.Session.CurrentRemoteForm.Equals("CURRENT TRANSACTION")))
			{
				server.Session.CurrentRemoteForm = server.Session.CurrentLocalForm;
			}
			array[3] = Util.ConvertToARFieldAssignmentList(serviceAction.InputFieldMapping, server.Session.GetServer(server.Session.SecondaryServerName), server.Session.CurrentLocalForm, server.Session.CurrentRemoteForm, false, false);
			array[4] = Util.ConvertToARFieldAssignmentList(serviceAction.OutputFieldMapping, server.Session.GetServer(server.Session.PrimaryServerName), serviceAction.FormName, server.Session.CurrentRemoteForm, false, false);
			array[5] = serviceAction.SampleServer;
			array[6] = serviceAction.SampleForm;
			return array;
		}
	}
}
